package com.auto.survey.activity.adjustment.adjustment_high.dao

import com.auto.survey.activity.adjustment.adjustment_high.entity.Project
import com.auto.survey.activity.adjustment.adjustment_high.entity.ProjectWithAllData
import com.auto.survey.base.CustomApplication
import com.auto.survey.database.AppDatabase

class AdjustmentRepository() {
    companion object {
        private val TAG:String = AdjustmentRepository::class.java.simpleName
    }
    private val db: AppDatabase = AppDatabase.getInstance(CustomApplication.getContext())
    private val adjustmentHighDao: AdjustmentHighDao = db.adjustmentHighDao()

    suspend fun addProject(project: Project):Long{
        return adjustmentHighDao.insertProject(project)
    }

    suspend fun deleteProjectById(prjectId:Int){
        adjustmentHighDao.deleteProjectById(prjectId)
    }
    suspend fun updateProject(project: Project):Int{
        return adjustmentHighDao.updateProject(project)
    }

    suspend fun queryAllProject():List<Project> {
        return adjustmentHighDao.getAllProjects()
    }

    suspend fun getProjectById(project_id:Int): ProjectWithAllData? {
        return adjustmentHighDao.getProjectWithAllData(project_id)
    }
}